home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM BV3 / BMUG PD-ROM Version BV3 (CDRM1097900).iso / QuickTime / QuickTime Utilities / E D T V / menu.c < prev    next >
Text File  |  1991-12-05  |  3KB  |  120 lines

  1. /****************************************************************************/
  2. /*                                                                            */
  3. /*    Application:    E D T V                                                    */
  4. /*                                                                            */
  5. /*    Description:    This file contains all the routines for handling        */
  6. /*                    menu events.                                            */
  7. /*                                                                            */
  8. /*    File:            menu.c                                                    */
  9. /*                                                                            */
  10. /*    Files:            about.c        - routines for the about box                */
  11. /*                    EDTV.c        - routines for displaying movies            */
  12. /*                    menu.c        - routines for handling the menu            */
  13. /*                    remote.c    - routines for controlling the movie        */
  14. /*                    EDTV.h        - header file information                    */
  15. /*                                                                            */
  16. /*    Programmer:        Edgar Lee                                                */
  17. /*    Organization:    Apple Computer, Inc.                                    */
  18. /*    Department:        Developer Technical Support, DTS                        */
  19. /*    Language:        C (Think C version 5.0)                                    */
  20. /*    Date Created:    10-26-91                                                */
  21. /*                                                                            */
  22. /****************************************************************************/
  23.  
  24. #include "EDTV.h"
  25.  
  26. MenuHandle appleMenu, fileMenu;
  27.  
  28. enum {
  29.     appleID = 1,
  30.     fileID
  31. };
  32.  
  33. enum {
  34.     openItem = 1,
  35.     closeItem,
  36.     quitItem = 4
  37. };
  38.  
  39. /*-------------------------------------------------------------------------------------*/
  40.  
  41. void setUpMenus()
  42. {
  43.     InsertMenu( appleMenu = NewMenu( appleID, "\p\024" ), 0 );
  44.     InsertMenu( fileMenu = NewMenu( fileID, "\pFile" ), 0 );
  45.  
  46.     DrawMenuBar();
  47.     
  48.     AppendMenu( appleMenu, "\pAbout E D T V...;(-" );
  49.     AddResMenu( appleMenu, 'DRVR' );
  50.     
  51.     AppendMenu( fileMenu, "\pLoad Movie.../O;Eject/W;(-;Power Off/Q" );
  52. }
  53.  
  54. /*-------------------------------------------------------------------------------------*/
  55.  
  56. void adjustMenus()
  57. {
  58.     register WindowPeek wp = (WindowPeek)FrontWindow();
  59.     short kind = wp ? wp->windowKind : 0;
  60.     Boolean DA = kind < 0;
  61.  
  62.     enable( fileMenu, quitItem, true );
  63.     enable( fileMenu, openItem, gMoviesStatus == NO_MOVIE );
  64.     enable( fileMenu, closeItem, gMoviesStatus == MOVIE_LOADED );
  65.     enable( fileMenu, quitItem, true );
  66. }
  67.  
  68. /*-------------------------------------------------------------------------------------*/
  69.  
  70. void enable( menu, item, ok )
  71. MenuHandle menu;
  72. {
  73.     if (ok)
  74.         EnableItem( menu, item );
  75.     else
  76.         DisableItem( menu, item );
  77. }
  78.  
  79. /*-------------------------------------------------------------------------------------*/
  80.  
  81. void handleMenu( mSelect )
  82. long mSelect;
  83. {
  84.     int                    menuID = HiWord( mSelect );
  85.     int                    menuItem = LoWord( mSelect );
  86.     GrafPtr                savePort;
  87.     Str255                name;
  88.     
  89.     switch (menuID)
  90.     {
  91.         case appleID:
  92.             if (menuItem == 1)
  93.                 doAboutBox();
  94.             else
  95.             {
  96.                 GetPort( &savePort );
  97.                 GetItem( appleMenu, menuItem, name );
  98.                 OpenDeskAcc( name );
  99.                 SetPort( savePort );
  100.             }
  101.             break;
  102.             
  103.         case fileID:
  104.             switch (menuItem)
  105.             {
  106.                 case openItem:
  107.                     selectMovie();
  108.                     break;
  109.                 case closeItem:
  110.                     closeMovie();
  111.                     break;
  112.                 case quitItem:
  113.                     quit();
  114.                     break;
  115.             }
  116.             break;
  117.     }
  118.     
  119.     HiliteMenu( 0 );
  120. }